<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
	<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
	<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
	
	<style type="text/css">
		*{padding:0;margin:0;font-family:微软雅黑;}
		.divv{font-family:微软雅黑;text-align: center;}
	</style>
	<title>TA-jsp-大学物理实验-十、实验24 等厚干涉</title>
</head>
<body class="text-center">

<nav class="navbar navbar-default navbar-fixed-top"><!--顶部栏-->
	<div class="container-fluid"><!--this is the nav-->
		
		<div class="navbar-header"><!--brand and phone nav-->
			<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
			<span class="sr-only">Toggle navigation</span>
			<span class="icon-bar"></span>
			<span class="icon-bar"></span>
			<span class="icon-bar"></span>
			</button>
			<a class="navbar-brand" href="#">TriAlley</a>
		</div>
		
		<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"><!--this is our-->
			<ul class="nav navbar-nav">
				<li class="active"><a href="#">项目链接</a></li>
			</ul>
		</div>
	</div>
</nav>

<br/><br/><br/>

<table class="table table-condensed">
	<thead>
		<tr>
			<th scope="row">m</th>
			<th>19</th>
			<th>18</th>
			<th>17</th>
			<th>16</th>
			<th>15</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<th scope="row">左刻度</th>
			<th><input name="cl" class='form-control' type="text" placeholder=""/></th>
			<th><input name="cl" class='form-control' type="text" placeholder=""/></th>
			<th><input name="cl" class='form-control' type="text" placeholder=""/></th>
			<th><input name="cl" class='form-control' type="text" placeholder=""/></th>
			<th><input name="cl" class='form-control' type="text" placeholder=""/></th>
		<tr/>
						<tr>
			<th scope="row">右刻度</th>
			<th><input name="cr" class='form-control' type="text" placeholder=""/></th>
			<th><input name="cr" class='form-control' type="text" placeholder=""/></th>
			<th><input name="cr" class='form-control' type="text" placeholder=""/></th>
			<th><input name="cr" class='form-control' type="text" placeholder=""/></th>
			<th><input name="cr" class='form-control' type="text" placeholder=""/></th>
		<tr/>
		<tr>
			<th scope="row">Dm</th>
			<th name="dm"></th>
			<th name="dm"></th>
			<th name="dm"></th>
			<th name="dm"></th>
			<th name="dm"></th>
		<tr/>
		<tr>
			<th scope="row">Dm^2</th>
			<th name="d2"></th>
			<th name="d2"></th>
			<th name="d2"></th>
			<th name="d2"></th>
			<th name="d2"></th>
		<tr/>
	</tbody>
	<thead>
		<tr>
			<th scope="row">n</th>
			<th>19</th>
			<th>18</th>
			<th>17</th>
			<th>16</th>
			<th>15</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<th scope="row">左刻度</th>
			<th><input name="cl" class='form-control' type="text" placeholder=""/></th>
			<th><input name="cl" class='form-control' type="text" placeholder=""/></th>
			<th><input name="cl" class='form-control' type="text" placeholder=""/></th>
			<th><input name="cl" class='form-control' type="text" placeholder=""/></th>
			<th><input name="cl" class='form-control' type="text" placeholder=""/></th>
		<tr/>
						<tr>
			<th scope="row">右刻度</th>
			<th><input name="cr" class='form-control' type="text" placeholder=""/></th>
			<th><input name="cr" class='form-control' type="text" placeholder=""/></th>
			<th><input name="cr" class='form-control' type="text" placeholder=""/></th>
			<th><input name="cr" class='form-control' type="text" placeholder=""/></th>
			<th><input name="cr" class='form-control' type="text" placeholder=""/></th>
		<tr/>
		<tr>
			<th scope="row">Dn</th>
			<th name="dm"></th>
			<th name="dm"></th>
			<th name="dm"></th>
			<th name="dm"></th>
			<th name="dm"></th>
		<tr/>
		<tr>
			<th scope="row">Dn^2</th>
			<th name="d2"></th>
			<th name="d2"></th>
			<th name="d2"></th>
			<th name="d2"></th>
			<th name="d2"></th>
		<tr/>
		<tr>
			<th scope="row">(D-D)</th>
			<th name="d2d2"></th>
			<th name="d2d2"></th>
			<th name="d2d2"></th>
			<th name="d2d2"></th>
			<th name="d2d2"></th>
		<tr/>
	</tbody>
</table>
<button class="btn btn btn-success" onclick="dox();">ok</button>

<div >
	<b>(Dm^2-Dn^2)平均=</b>
	<b id="pj"></b>
	<br/>

	<b>R=</b>
	<b id="r"></b>
	<br/>

	<b>Σ=</b>
	<b id="sgm"></b>		<br/>

	<b>σ(Dm^2-Dn^2)=</b>
	<b id="ssgm"></b>		<br/>

	<b>σR=</b>
	<b id="ssgmr"></b>		<br/>

	<b>E=</b>
	<b id="e"></b>		<br/>
</div>
</body><!--可见部分结束-->

<script type="text/javascript">
	var c = new Array(4)
	var num=new Array(4)
	for(var i=1;i<=4;i++){
	  	num[i]=new Array(10)
	}
	var cb=document.getElementsByName("d2d2")

	var pj=0
	var r=0
	var sgm=0
	var ssgmr=0
	var e=0
	var ssgm=0

	function dox(){

		getObj()
		ObjToNum()
		calNum()
		NumToObj()

		setcbandpj()
		setr()
		setsgm()
		setssgm()
		setssgmr()
		sete()
		console.log("all done")
	}
	function getObj(){//获得页面操作对象
		c[1]=document.getElementsByName("cl")
		c[2]=document.getElementsByName("cr")
		c[3]=document.getElementsByName("dm")
		c[4]=document.getElementsByName("d2")
		console.log("getObj() done")

	}
	function ObjToNum(){//将操作对象中的数值放到Num中去
		for(var i=0;i<=9;i++){
			num[1][i]=parseFloat(c[1][i].value)
			console.log(i,num[1][i])
		}
		for(var i=0;i<=9;i++){
			num[2][i]=parseFloat(c[1][i].value)
			console.log(i,num[2][i])
		}
		console.log("ObjToNum() done")
	}
	function calNum(){//对Num进行运算
		for(var i=0;i<=9;i++){
			num[3][i]=num[1][i]+num[2][i]
			num[4][i]=num[3][i]*num[3][i]
			console.log(i,num[3][i],num[4][i])
		}
		console.log("calNum() done")
	}
	function NumToObj(){//将Num运算结果放到操作对象中去
		c[3][7].innerHTML=1
		c[4][9].innerHTML=1
		for(var i=0;i<=9;i++){
			c[3][i].innerHTML=num[3][i]
			c[4][i].innerHTML=num[4][i] 
			console.log(i,c[3][i],c[4][i])
		}
		console.log("NumToObj done")
	}
	function setcbandpj(){

		for(i=0;i<=4;i++){
			cb[i].innerHTML=(num[4][i]*num[4][i]-num[4][i+5]*num[4][i+5])
			pj=pj+parseFloat(cb[i].innerHTML)
			console.log("cb"+i+":",cb[i])
		}
		pj=pj/5
		console.log("pj:"+pj)

		document.getElementById("pj").innerHTML=pj
		console.log("setcbandpj() done")	
	}
	function setr(){
		r=(pj/5)/(4*5*589.3)
		document.getElementById("r").innerHTML=r
		console.log("r:"+r)
		console.log("setr() done")
	}
	function setsgm(){
		for(i=0;i<=4;i++){
			sgm=sgm+(pj-parseFloat(cb[i].innerHTML))*(pj-parseFloat(cb[i].innerHTML))
		}
		document.getElementById("sgm").innerHTML=sgm
		console.log("sgm:"+sgm)
		console.log("setsgm() done")
	}
	function setssgm(){
		ssgm=Math.sqrt(sgm/90)
		document.getElementById("ssgm").innerHTML=ssgm
		console.log("ssgm:"+ssgm)
		console.log("setssgm() done")
	}
	function setssgmr(){
		ssgmr=(ssgm/(4*5*589.3))
		document.getElementById("ssgmr").innerHTML=ssgmr
		console.log("ssgmr:"+ssgmr)		
		console.log("setssgmr() done")
	}
	function sete(){
		e=(ssgmr/r)
		document.getElementById("e").innerHTML=e
		console.log("e:"+e)
		console.log("sete() done")
	}
</script>
</html>
